# -*- coding: utf-8 -*-
from match import Extractor
import regex as re


class WeiXianJiaShiBianHuExtractor(Extractor):

    # 该辩护要点仅仅适用于危险驾驶
    @staticmethod
    def is_my_job(file_path):
        return "危险驾驶" in file_path

    @staticmethod
    def extract(text):
        result = {}
        bian_hu_list = list(set(re.findall(r"(没有犯罪故意|未追逐竞驶|未造成严重后果|未超速超载|未醉酒驾驶|精神病人|初犯|无前科|从犯|胁从犯|认罪|认罚|自首|坦白|立功|悔罪表现|被害人过错|被害人谅解|程序违法)", text)))
        result["辩护要点"] = bian_hu_list

        #肇事逃逸
        zhao_shi_tao_yi = re.search(r"(肇事逃逸|逃避事故责任|逃离事故现场|弃车逃逸)", text) is not None
        result["肇事逃逸"] = zhao_shi_tao_yi

        return result


if __name__ == '__main__':
    print(WeiXianJiaShiBianHuExtractor.extract("被告没有真正实施盗窃行为，还属于胁从犯，没有事先预谋是未成年人。"))
    print(WeiXianJiaShiBianHuExtractor.extract("遇情况采取措施不力是引发本次事故的主要原因，钟德平违章肇事逃逸应负本次事故的主要责任；"))
